import request from "./request"
import {message} from "antd"
// const BASE_URL = 'http://localhost:9999'

export default (url, data = {}, type = 'POST') => {

    return new Promise((resolve, reject) => {
        let promise
        if(type === 'GET'){
            promise = request.get(url, { params: data })
        }else{
            promise = request.post(url, data)
        }

        promise.then(response => {
            resolve(response.data)
        }).catch(error => {
            message.error('请求出错了：' + error.message)
            reject(error)
        })
    })
    
    
}

